/**
 * Created by Administrator on 2016/5/4.
 */
(function () {
    angular.module('hearthstone_deck_management')
        .directive('addCard', function () {
            return {
                restrict: 'E',
                templateUrl: 'templates/add_card.html',
                scope: {},
                require: '^deckCardArea',
                link: function (scope, element, attr, deckCardArea) {
                    scope.card = {};
                    // 添加卡牌
                    scope.addCard = function (card) {
                        deckCardArea.addCard(card);
                        scope.card = {};
                    };
                    // 验证卡牌
                    scope.valid = function (card) {
                        if(null == card.name || '' == card.name) {
                            alert('卡牌名称不能为空！');
                            return false;
                        } else {
                            return true;
                        }
                    }
                }
            };
        })
})();
